<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>电子券设置</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="__INDEX__/store/js/mui.min.js"></script>
	    <link href="__INDEX__/store/css/mui.min.css" rel="stylesheet"/>
		<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/store/css/newsj.css" />
	</head> 
	<body>
		<header class="mui-bar mui-bar-nav" >
		    <a class="mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
		    <h1 class="mui-title">电子券设置</h1>
		</header>
		<div class="mui-content">
			<div class="line"></div>
			<input type="hidden" id='id' value="{$set_info['id']}">
		    <div class="dzqsz_item">
				<div class="bt clearfix">
					<label type='1'>请输入购买面额</label>
					<input type="text" placeholder="0.00" class="dzq_input one" onkeyup="clearNoNums(this,1)"/>
				</div>
				<div class="dzqsz_dzq">
					<div class="dzyhq_box clearfix">
						<div class="left">¥<em id="on">{$set_info['one_money']}</em></div>
						<div class="right clearfix"><em id="glj">{$set_info['one_money']*4}</em>鼓励金</div>
					</div>
				</div>				
			</div>
		    <div class="dzqsz_item">
		    	<div class="tips">电子券购买金额设置2</div>
				<div class="bt clearfix">
					<label>请输入购买面额</label>
					<input type="text" placeholder="0.00" class="dzq_input two" onkeyup="clearNoNums(this,2)"/>
				</div>
				<div class="dzqsz_dzq">
					<div class="dzyhq_box clearfix">
						<div class="left">¥<em id="two">{$set_info['two_money']}</em></div>
						<div class="right clearfix"><em id="glj2">{$set_info['two_money']*4}</em>鼓励金</div>
					</div>
				</div>				
			</div>
			<div class="dzqsz_item">
				<div class="tips">电子券购买金额设置2</div>
				<div class="bt clearfix">
					<label>请输入购买面额</label>
					<input type="text" placeholder="0.00" class="dzq_input three" onkeyup="clearNoNums(this,3)"/>
				</div>
				<div class="dzqsz_dzq">
					<div class="dzyhq_box clearfix">
						<div class="left">¥<em id="three">{$set_info['three_money']}</em></div>
						<div class="right clearfix"><em id="glj3">{$set_info['three_money']*4}</em>鼓励金</div>
					</div>
				</div>				
			</div>
			<button type="button" class="tjsyy_btn dzq_btn" onclick="gm()">生成购买码</button>
		</div>
		
	</body>

</html>

<script type="text/javascript" src="__INDEX__/store/js/jquery.min.js"></script>
<script type="text/javascript" src="__INDEX__/store/js/layer/layer.min.js"></script>
<script>
    function clearNoNums(obj,type)
	{
		obj.value = obj.value.replace(/[^\d]/g, ""); //清除“数字”和“.”以外的字符
		obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
		obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
		obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
		if(type == 1){
				$("#on").text(parseFloat(obj.value)); 
				$("#glj").text(parseFloat(obj.value)*4); 
		}
	    if(type == 2){
				$("#two").text(parseFloat(obj.value)); 
				$("#glj2").text(parseFloat(obj.value)*4); 
		}
		if(type == 3){
				$("#three").text(parseFloat(obj.value)); 
				$("#glj3").text(parseFloat(obj.value)*4); 
		}
	   
	}

	function gm() {
		var one = $('.one').val();
		var two = $('.two').val();
		var three = $('.three').val();
		var id = $('#id').val();  
		if(one == '' && two == '' && three == ''){
		   window.location.href="gljgmm";
		}else{ 
			$.ajax({
				type:'post',
				url: "{:url('agent/edit_dzq')}" ,
				data: {
					id: id,
					one_money: one,
					two_money: two,
					three_money: three
				},
				success: function(data) {  
					if(data.code == 200) {
						layer.msg(data.msg,{icon:1},function(){
							 window.location.href="gljgmm";
						});
	
					} else {
						layer.msg(data.msg);
						console.log(data.msg);
					}
				}
			})
		}
	}
</script>